package com.hy.controller;

import common.pojo.Products;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:
 * author: Mr.Du
 * Date: 2022/11/1
 * Time: 12:30
 */
@RestController
@RequestMapping("/page")
public class PageController {
    @Resource
    private RestTemplate restTemplate;
    
    @GetMapping("/query/{id}")
    public Products getProductById(@PathVariable int id){
        Products products = restTemplate.getForObject("http://localhost:9999/product/query/" + id, Products.class);
        return products;
    }
}
